package com.game.logic.channel;

import io.netty.channel.Channel;
import io.netty.channel.ChannelPromise;
import io.netty.util.concurrent.Future;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class ClientChannelContext {
    private Channel channel;
    private long userId;

    public ClientChannelContext(long userId, Channel channel) {
        super();

        this.channel = channel;

        this.userId = userId;
    }

    public Channel getChannel() {
        return channel;
    }

    public long getUserId() {
        return userId;
    }

    public Future<?> writeAndFlush(Object msg) {
        return channel.writeAndFlush(msg);
    }

    public Future<?> writeAndFlush(Object msg, ChannelPromise promise) {
        return channel.writeAndFlush(msg, promise);
    }

    public void sendEvent(Object msg) {
        this.channel.pipeline().fireUserEventTriggered(msg);
    }
}
